<cfprocessingdirective suppresswhitespace="yes">
<!--- 
***** REVISION *****
10/18/06: This is a new tag
 --->	
<cfswitch expression="#thisTag.executionMode#">
	<cfcase value="start">
		<cfsavecontent variable="attributeCombination">
		<strong>Attribute Available are:</strong>
		<LI>Optional attributes: NAME, ID, DSN, CSS, BREAK, THEME, THEMEPATH,  SHOWBUTTONS, SHOWSUBMIT, SHOWCANCEL, SHOWRESET, SUBMIT, CANCEL, RESET, and CANCELURL.
		</cfsavecontent>

		<cfset tag = "form"/>
		<cfset excludes = "css,break,parent,theme,themePath,themeFile,libAbsPath,dsn,excludes,required,classRequired,showbuttons,showsubmit,showcancel,showreset,submit,cancel,reset,default,legend,classLegend,cancelURL"/>
		<cfinclude template="inc_functions.cfm"/>

		<cfset formtag = structNew()/>
		<cfset formtag.html = duplicate(attributes)/>		
		<cfset formtag.config = duplicate(attributes)/>

		<cfset faVariable = application.fusebox.fuseactionVariable/>
		<cfset currentFa = caller.myfusebox.ORIGINALFUSEACTION/>
		<cfset currentCircuit = caller.myfusebox.ORIGINALCIRCUIT/>
		<cfset index = listLast(cgi.SCRIPT_NAME,'/')/>
		
		
		<!--- Processing Name --->
		<cfif NOT structKeyExists(attributes,"name")>
			<cfif structKeyExists(attributes,"id")>
				<cfset attributes.name=attributes.id/>
			<cfelseif structKeyExists(attributes,"action")>
				<cfset fa = listFirst(attributes.action,"&?")/>		
				<!--- apply to action like create and create&id=10--->				
				<cfif listlen(fa,'.') eq 1>
					<cfset attributes.name = fa/>
				<!--- apply to action like mem.create and mem.create&id=10, but not index.cfm or index.cfm?fuseaction=mem.create --->
				<cfelseif listlen(fa,'.') eq 2 AND compareNoCase(listLast(cgi.SCRIPT_NAME,'/'),fa)>
					<cfset attributes.name = listLast(fa,'.')/>
				<cfelse>
					<cfset faPosition = listFindNoCase(attributes.action, faVariable, "?=&.")/>			
					<cfif faPosition>
						<cfset attributes.name = listGetAt(attributes.action,faPosition+2,'?=&.')/>
					</cfif>
				</cfif>
			<cfelseif isDefined("request.ui.form.#tag#.html") and structKeyExists(request.ui.form[tag].html,'name')>
				<cfset attributes.name = request.ui.form[tag].html.name/>
			<cfelse>
				<cfset attributes.name = currentFa/>
			</cfif>
		</cfif>
		<cfif structKeyExists(attributes, "name")>
			<cfset attributes.name = listLast(attributes.name,'.')/>
		</cfif>
		<!--- End processing name --->
		
		
		<!--- *** CONFIG VARIABLES *** --->
		<!--- Adding config variables for specific form name --->
		<cfset config = getConfig(tag,attributes,request)/>
		
		<!--- *** HTML VARIABLES *** --->
		<!--- Adding html variables for specific form name --->
		<cfset attributes = getHtml(tag,attributes,request)/>

		<!--- Process action --->
		<cfif structKeyExists(attributes, "action")>
			<cfset fa = listFirst(attributes.action,"&?")/>			
			<!--- apply to action like id=10 and id=10&type=member --->
			<cfif listLen(fa,'=') eq 2 AND listFirst(fa,'=') neq faVariable>
				<cfset attributes.action="#index#?#faVariable#=#caller.attributes[faVariable]#&#attributes.action#"/>
			<!--- apply to action like create and create&id=10--->				
			<cfelseif listlen(fa,'.') eq 1>
				<cfset attributes.action="#index#?#faVariable#=#currentCircuit#.#attributes.action#"/>			
			<!--- apply to action like member.create and member.create&id=10, but not index.cfm or index.cfm?fuseaction=member.create --->
			<cfelseif listlen(fa,'.') eq 2 AND compareNoCase(listLast(cgi.SCRIPT_NAME,'/'),fa)>
				<cfset attributes.action="#index#?#faVariable#=#attributes.action#"/>
			</cfif>
		<cfelse>
			<cfif listlen(attributes.name,'.') eq 2>
				<cfset attributes.action="#index#?#faVariable#=#attributes.name#"/>
			<cfelseif len(cgi.QUERY_STRING)>
				<cfset attributes.action="#index#?#cgi.QUERY_STRING#"/>		
			</cfif>
		</cfif>
		<cfparam name="attributes.action" default="#index#?#faVariable#=#currentCircuit#.#attributes.name#"/>

		<cfif structKeyExists(attributes, "id")>
			<cfset attributes.id=listLast(attributes.id,'.')/>			
		</cfif>		
		<cfparam name="attributes.id" default="#attributes.name#"/>
		<cfparam name="config.theme" default="default"/>
		<cfparam name="config.themePath" default="themes"/>
		<cfparam name="attributes.method" default="post"/>
		<cfparam name="attributes.style" default="margin:0px"/>
		<cfparam name="config.labelPosition" default="left"/>
		<cfparam name="config.break" default="true"/>
		<cfparam name="config.required" default="false"/>
		<cfparam name="config.classRequired" default="required"/>
		<cfparam name="config.css" default="true"/>
		<cfparam name="config.classLabel" default="label"/>
		<cfparam name="config.cssLabelCode" default="false"/>
				
		<cfparam name="config.showButtons" default="true"/>
		<cfparam name="config.showSubmit" default="true"/>
		<cfparam name="config.showCancel" default="true"/>
		<cfparam name="config.showReset" default="true"/>
		<cfparam name="config.submit" default="Submit"/>
		<cfparam name="config.cancel" default="Cancel"/>
		<cfparam name="config.reset" default="Reset"/>
		<cfparam name="config.cancelURL" default="#index#"/>		
		<cfparam name="config.radio.size" default="0"/>
		<cfparam name="config.checkbox.size" default="0"/>

		<cfset config.cssCode=structNew()/>

		<cfif structKeyExists(config,'excludes')>
			<cfset config.excludes = config.excludes & "," & excludes/>
		</cfif>
		<cfparam name="config.excludes" default="#excludes#"/>
		
		<cfif listFirst(config.cancelURL,'?&') neq index>
			<cfif listLen(listFirst(config.cancelURL,'&'),'.') eq 2>
				<cfset config.cancelURL = index & "?" & faVariable & "=" & config.cancelURL/>
			<cfelse>
				<cfset config.cancelURL = index & "?" & faVariable & "=" & currentCircuit & "." & config.cancelURL/>
			</cfif>
		</cfif>
	</cfcase>
	
	
	<cfcase value="end">
		<!--- Get Theme to display --->
		<cftry>
			<cfinclude template="#config.themePath#/#config.theme#/config.properties.cfm"/>
			<cfcatch type="missinginclude">
			</cfcatch>
		</cftry>
		<cfsavecontent variable="thisTag.generatedContent">
			<cftry>
				<cfinclude template="#config.themePath#/#config.theme#/#tag#.cfm"/>
				<cfcatch type="missinginclude">
					<cftry>
						<cfinclude template="themes/default/config.properties.cfm"/>					
						<cfinclude template="themes/default/#tag#.cfm"/>						
						<cfcatch type="missinginclude">
							<cfset showException(tag,'Your theme is missing. Make sure you specify the correct path.',2)/>						
						</cfcatch>
					</cftry>
				</cfcatch>
			</cftry>
		</cfsavecontent>
		<cfset thisTag.generatedContent = ReReplace(trim(thisTag.generatedContent), '(?m)^\s+\r\n','', "ALL")>
	</cfcase>
</cfswitch>
</cfprocessingdirective>